import { createRouter, createWebHistory } from 'vue-router'
// import NProgress from '@/config/nprogress.js'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: "/",
      component: () => import('@/views/index/index.vue'),
      redirect: '/login',
      children: [
        {
          path: '/login',
          name: 'login',
          component: () => import('@/views/login/index.vue'),
        },
        {
          path: '/register',
          name: 'register',
          component: () => import('@/views/register/index.vue'),
        },
      ]

    },
    {
      path: '/home',
      name: 'home',
      component: () => import('@/views/home/index.vue'),
      redirect: '/home/index',
      children: [
        {
          path: 'index',
          name: 'home-index',
          component: () => import('@/views/main/index.vue'),
        },
        {
          path: 'resource',
          name: 'home-resource',
          component: () => import('@/views/resource/index.vue'),
        },
        {
          path: 'partner',
          name: 'home-partner',
          component: () => import('@/views/partner/index.vue'),
        },
        {
          path: 'plan',
          name: 'home-plan',
          component: () => import('@/views/plan/index.vue'),
        },
        {
          path: 'mine',
          name: 'home-mine',
          component: () => import('@/views/mine/index.vue'),
        },
      ],
    },
    {
      path:'/center',
      name:'center',
      component:()=>import('@/views/center/index.vue')
    },
    {
      path:'/password',
      name:'password',
      component:()=>import('@/views/password/index.vue')
    },
    {
      path:'/my/collect',
      name:'my-collect',
      component:()=>import('@/views/my-collect/index.vue')
    },
    {
      path:'/my/post',
      name:'my-post',
      component:()=>import('@/views/my-post/index.vue')
    },
    {
      path:'/plan/detail/:id',
      name:'plan-detail',
      props:true,
      component:()=>import('@/views/plan-detail/index.vue')
    },
    {
      path:'/post',
      name:'home-post',
      component:()=>import('@/views/post/index.vue')
    },
    {
      path:'/post/detail/:id',
      props:true,
      name:'post-detail',
      component:()=>import('@/views/post-detail/index.vue')
    },
    {
      path:'/add/friend',
      name:'add-friend',
      component:()=>import('@/views/add-friend/index.vue')
    },
    {
      path:'/apply/record',
      name:'apply-record',
      component:()=>import('@/views/apply-record/index.vue')
    },
    {
      path:'/message/:friendId/:userId',
      name:'message',
      component:()=>import('@/views/message/index.vue')
    },
  ],
})

router.beforeEach((to, from, next) => {
  next()
})

router.afterEach(() => {
})

export default router
